package com.test.java;

import java.text.DecimalFormat;
import java.util.Scanner;

/**
 * 假如我们有3种月饼，其库存量分别为18、15、10万吨，总售价分别为75、72、45亿元。
 * 如果市场的最大需求量只有20万吨，那么我们最大收益策略应该是卖出全部15万吨第2种月饼、以及5万吨第3种月饼，
 * 获得72 + 45/2 = 94.5（亿元）。
 * =============================================================
 * Version          Author          Date            Description
 * 1.0              白建         2017/12/20             创建
 * =============================================================
 */
public class Java_11
{

    private static short TYPE;

    private static short REQUIREMENT;

    private static short[][] INPUT;

    private static double[] PRICE;

    private static DecimalFormat df = new DecimalFormat("#.00");

    public static void main(String[] args)
    {

        init();
        process();
    }

    private static void init()
    {

        Scanner scanner = new Scanner(System.in);
        TYPE = scanner.nextShort();
        REQUIREMENT = scanner.nextShort();
        INPUT = new short[TYPE][2];
        PRICE = new double[TYPE];

        int i = 0;
        for (; i < TYPE; i++)
        {
            INPUT[i][0] = scanner.nextShort();
        }
        for (i = 0; i < TYPE; i++)
        {
            INPUT[i][1] = scanner.nextShort();
        }
        for (i = 0; i < TYPE; i++)
        {
            PRICE[i] = INPUT[i][1] / (double) INPUT[i][0];
        }
    }

    private static void process()
    {

        double profit = 0.0;
        boolean satisfy = false;

        while (!satisfy)
        {
            int maxIndex = 0;
            for (int i = 0; i < TYPE; i++)
            {
                if (PRICE[i] > PRICE[maxIndex])
                {
                    maxIndex = i;
                }
                else if (PRICE[i] == PRICE[maxIndex] && INPUT[i][0] > INPUT[maxIndex][0])
                {
                    maxIndex = i;
                }
            }

            if (INPUT[maxIndex][0] >= REQUIREMENT)
            {
                satisfy = true;
                profit += REQUIREMENT * PRICE[maxIndex];
            }
            else
            {
                REQUIREMENT = (short) (REQUIREMENT - INPUT[maxIndex][0]);
                profit += INPUT[maxIndex][1];
                PRICE[maxIndex] = -1;
            }
        }

        System.out.println(df.format(profit));
    }
}
